﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Net.Http;


namespace Shop
{
    public class IndexAttachment
    {
        #region 第一次调用上传附件的主目录
        public static HttpResponseMessage mainswith(MultipartFileData file)
        {
            try
            {
                string path = HttpContext.Current.Request.Url.AbsolutePath;
                string[] switchNames = path.Split(new string[] { "/" }, StringSplitOptions.RemoveEmptyEntries);
                //if (switchNames.Length <=1) {  return Common.HandleJson.ToJson(Common.ReturnValue.ErrAction()); }
                string mainname = switchNames[2];
                Dictionary<string, object> dic = new Dictionary<string, object>();
                List<Dictionary<string, object>> list = System.Web.HttpContext.Current.Request.Form.GetList("data");
                switch (mainname)
                {
                    case "CustomerHeadImage":
                        dic = Implementation.Customer.CustomerHeadImage.afterSave_CustomerHeadImg(file);
                        break;                       
                    default:
                        dic = Common.ReturnValue.ErrAction();
                        break;
                }
                return Common.HandleJson.ToJson(dic);
            }
            catch (Exception ex)
            {
                System.Reflection.MethodBase.GetCurrentMethod().WriteErrLog(HttpContext.Current.Request.Url.AbsoluteUri + "|" + ex.Message);
                return Common.HandleJson.ToJson("出现错误，请与我公司4008237007联系处理，谢谢！", false);
            }
        }
        #endregion
    }
}